package com.sm.tools;

import java.util.ArrayList;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.sm.R;
import com.sm.activities.ShowStudentActivity;
import com.sm.activities.WelcomeActivity;
import com.sm.activities.subscriptionmanager.StudentsManager_Tab;
import com.sm.bo.Course;
import com.sm.bo.Student;

public class SMDialog_Cours extends AlertDialog implements android.view.View.OnClickListener{
	private Course cours;
	private Context context;
	private String title;
	private Intent intent;

	Activity activity;
	MyCustomCourseAdapter coursListAdapter;

	Button showCours;
	Button RemoveCours;
	Button cancelCours;

	public SMDialog_Cours(Context context, String title, Intent intent,
			MyCustomCourseAdapter adapter) {
		super(context);
		this.context = context;
		this.title = title;
		this.intent = intent;
		this.coursListAdapter = adapter;
	}

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_action_on_student);

		this.setTitle(title);
		this.setCancelable(true);

		cours = intent.getExtras().getParcelable("cours");
	((TextView) findViewById(R.id.txt_SNameToManage)).setText(cours.getWording());

		showCours = (Button) findViewById(R.id.btn_Show_Student);
		showCours.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				ArrayList<String> courses = new ArrayList<String>();
//				courses.add("Course 1");
//				courses.add("Course 2");
//				
//				cours.set.setCourses(courses);
//				Intent intent = new Intent(context, ShowStudentActivity.class);
//				intent.putExtra("student", student);
//				context.startActivity(intent);
			}
		});

		RemoveCours= (Button) findViewById(R.id.btn_Del_Student);
		RemoveCours.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				StudentsManager_Tab.DIALOG_STUDENT_REMOVED = 1;

//				WelcomeActivity.studentsList
//						.remove(WelcomeActivity.studentsList.indexOf(student));
//				studentListAdapter.notifyDataSetChanged();

				dismiss();
			}
		});

		cancelCours = (Button) findViewById(R.id.btn_Cancel_Student);
		cancelCours.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				StudentsManager_Tab.DIALOG_STUDENT_REMOVED = 0;
				dismiss();
			}
		});

	}

	// Autocomplete function
	// See:
	// 1.
	// http://tseng-blog.nge-web.net/blog/2009/02/17/how-implement-your-own-listener-android-java/

	public void onClick(View v) {
		context.startActivity(intent);
		dismiss();
	}
}
